﻿Imports System.IO

Public Class frmAppSettings

  '========================================================================================
  '
  '   Filename : frmAppSettings.vb
  '
  '   Description: Provides access to all Application level settings
  '
  '   Called By: Main : mnuSettings_Click
  '
  '   Calls:
  '
  '   Version: 1.0.0
  '
  '   Date:6 Feb 2017
  '
  '========================================================================================

  '========================================================================================
  '          PRIVATE CONSTANTS
  '========================================================================================
  Private cstrSetupFileName As String = "KenMemSetup"
  Private CStrSettingsFileExt As String = ".stg"

  '========================================================================================
  '          PUBLIC CONSTANTS
  '========================================================================================

  '========================================================================================
  '          PRIVATE VARIABLES
  '========================================================================================
  Private fApplicationPath As String
  Private fSetupFileName As String
  Private fKenMemPath As String
  Private fKenMemDataPath As String
  Private fRadiosPath As String
  Private fUseLastRadio As Boolean = True

  '========================================================================================
  '          PUBLIC VARIABLES
  '========================================================================================

  '========================================================================================
  '          PRIVATE ROUTINES
  '========================================================================================

  '========================================================================================
  '          PUBLIC ROUTINES
  '========================================================================================

  '========================================================================================
  '          PROPERTY ROUTINES
  '========================================================================================
  Public Property ApplicationPath() As String

    Get
      Return fApplicationPath
    End Get

    Set(ByVal path As String)
      fApplicationPath = path
    End Set

  End Property 'Public Property fApplicationPath

  '----------------------------------------------------------------------------------------
  Public Property SetupFileName() As String

    Get
      Return fSetupFileName
    End Get

    Set(ByVal FileName As String)
      fSetupFileName = FileName
    End Set

  End Property 'Public Property SetupFileName() As String

  '----------------------------------------------------------------------------------------
  Public Property KenMemPath() As String

    Get
      Return fKenMemPath
    End Get

    Set(ByVal path As String)
      fKenMemPath = path
    End Set

  End Property 'Public Property KenMemPath

  '----------------------------------------------------------------------------------------
  Public Property KenMemDataPath() As String

    Get
      Return fKenMemDataPath
    End Get

    Set(ByVal path As String)
      fKenMemDataPath = path
    End Set

  End Property 'Public Property KenMemDataPath

  '----------------------------------------------------------------------------------------
  Public Property RadiosPath() As String

    Get
      Return fRadiosPath
    End Get

    Set(ByVal path As String)
      fRadiosPath = path
    End Set

  End Property 'Public Property RadiosPath

  '----------------------------------------------------------------------------------------
  Public Property UseLastRadio() As Boolean

    Get
      Return fUseLastRadio
    End Get

    Set(ByVal Value As Boolean)
      fUseLastRadio = Value
    End Set

  End Property 'Public Property RVMRadioPath


  '========================================================================================


  '========================================================================================
  '          MENU ROUTINES
  '========================================================================================

  '========================================================================================
  '          COMMAND BUTTON ROUTINES
  '========================================================================================
  Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
    Me.Close()
  End Sub 'Private Sub btnCancel_Click

  '========================================================================================
  Private Sub btnHelp_Click(sender As Object, e As EventArgs) Handles btnHelp.Click
    Me.Close()
  End Sub 'Private Sub btnHelp_Click

  '========================================================================================
  Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
    Me.Close()
  End Sub 'Private Sub btnOK_Clic

  '========================================================================================
  '          CONTROL ROUTINES
  '========================================================================================

  '========================================================================================
  '          FILE ROUTINES
  '========================================================================================
  Public Function SetupFileExists() As Boolean

    SetupFileName = ApplicationPath + "\" + cstrSetupFileName + CStrSettingsFileExt
    If My.Computer.FileSystem.FileExists(SetupFileName) Then
      Return True
    Else
      Return False
    End If 'If My.Computer.FileSystem.FileExists

  End Function 'Public Function SetupFileExist

  '----------------------------------------------------------------------------------------
  Public Sub ReadSetupFile()

    Try
      ' Create an instance of Stream Reader to read from a file.
      ' The using statement also closes the Stream Reader.
      Using sr As StreamReader = New StreamReader(SetupFileName)
        Dim line As String
        ' Read and display lines from the file until the end of
        ' the file is reached.
        line = sr.ReadLine()        'File Version number
        KenMemPath = sr.ReadLine()
        KenMemDataPath = sr.ReadLine()
        RadiosPath = sr.ReadLine()
      End Using
    Catch e As Exception
      'Let the user know what went wrong.
      MessageBox.Show(e.Message)
    End Try

  End Sub 'Public Sub ReadSetupFile


  '========================================================================================
  '          FORM ROUTINES
  '========================================================================================
  Private Sub frmAppSettings_Load(sender As Object, e As EventArgs) Handles MyBase.Load

  End Sub 'Private Sub frmAppSettings_Load

  '========================================================================================
  Private Sub frmAppSettings_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown

    tbxApplicationPath.Text = ApplicationPath
    tbxKenMemPaTH.Text = KenMemPath
    tbxKenMemDataPath.Text = KenMemDataPath
    tbxRadiosPath.Text = RadiosPath
    chkUseLastRadio.Checked = UseLastRadio

  End Sub ' Private Sub frmAppSettings_Shown


  '========================================================================================

End Class'Public Class AppSettiings